/**
 * Define your components
 */
// For 404 page
$(function () {
  const app = new Vue({
    data: function () {
      return {
        pack_form: package_row,
        start_datetime: '',
        end_datetime: '',
        button_message: package_row.user_id ? '修改包货信息' : '领取包货',
        person_qty: 1,
      }
    },
    methods: {
      onSubmit: function (order_id) {

      },
      pack_done: function (package_id) {
        this.$http.post('/wx/product/package/done',
          {
            id: package_id
          }).then(function (data) {
            this.pack_form.is_done=true
        })
      },
      get_pack_task: function (package_id) {
        if(!this.start_datetime&&!this.end_datetime&&!this.person_qty&&this.user_id){
          this.$message('你没有填充任何信息')
        }
        this.$http.post('/wx/product/package/write',
          {
            start_datetime: this.start_datetime ? this.start_datetime : '',
            end_datetime: this.end_datetime ? this.end_datetime : '',
            person_qty: this.person_qty || '',
            id: package_id
          }).then(function (data) {
          if (!data.body.error) {
            this.button_message = '修改包货信息'
            var retun_val = data.body.result
            this.pack_form.start_datetime = retun_val.start_datetime
            this.pack_form.end_datetime = retun_val.end_datetime
            this.pack_form.person_qty = retun_val.person_qty
            this.pack_form.user_id = retun_val.user_id
          } else {
            var h = this.$createElement
            this.$message(data.body.error.message)

          }
        })
      },
    },
    watch: {},
    created: function () {

    },
  }).$mount('#product_package')
})


